home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 19 code / SimpliFace_V2 / Sources / WindowObj.h < prev   
Encoding:
C/C++ Source or Header  |  1994-05-01  |  5.8 KB  |  241 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        WindowObj.h
  3.  
  4.     Contains:    Windows for a simple Scriptable application.
  5.  
  6.     Developed by:
  7.  
  8.     Paul G Smith (commstalk hq & Full Moon Software, Inc)
  9.  
  10.     you can leave messages at (UK): 0727 844232; (US): 408 253 7199
  11.     BUT I prefer to be contacted by e-mail
  12.     AppleLink:     COMMSTALK.HQ
  13.     Internet:     COMMSTALK.HQ@applelink.apple.com
  14.  
  15.     "SimpliFace2" Sample code to accompany develop article
  16.     on techniques for controlling script inheritance.
  17.     
  18.     
  19.  
  20. */
  21.  
  22. #ifndef __WINDOWOBJ__
  23. #define __WINDOWOBJ__
  24.  
  25. #ifndef __SCRIPTOBJECTS__
  26. #include "ScriptableObjects.h"
  27. #endif
  28.  
  29. #ifndef __PASCALSTRING__
  30. #include "PascalString.h"
  31. #endif
  32.  
  33. #ifndef __CONTROLS__
  34. #include "Controls.h"
  35. #endif
  36.  
  37. #ifndef __WINDOWS__
  38. #include <Windows.h>
  39. #endif
  40.  
  41. /**********************************************************************
  42. ** class TWindowObj
  43. ***********************************************************************/
  44.  
  45. class TWindowObj : public TScriptableObject {
  46. public:
  47.                                 TWindowObj(TScriptableObject* curParent);
  48.                                 TWindowObj(TScriptableObject* curParent,
  49.                                             const AEDesc *theData);
  50.     virtual                        ~TWindowObj();
  51.  
  52.     virtual    void    ActivateWindow(Boolean isActivating);
  53.  
  54.     virtual    void    UpdateWindow(void);
  55.  
  56.     virtual    void    DrawAllElements(DescType desiredClass);
  57.  
  58.     virtual    void    DrawWindow(void);
  59.  
  60.     virtual    TScriptableObject*    FindElement(Point& thePt, DescType desiredClass);
  61.     
  62.     virtual  OSErr OpenObject  (void);
  63.                                         
  64.     virtual  OSErr CloseObject  (void);
  65.                                         
  66.     
  67.     virtual  OSErr CountElements (DescType desiredClass,
  68.                                         long *result);
  69.                                         
  70.     virtual  OSErr ResolveContainer    (TScriptableObject **theContainerObj);
  71.  
  72.     virtual  OSErr ResolveElementByName(DescType desiredClass,
  73.                                         CStr255& nameStr,
  74.                                         TScriptableObject **theResultObj);
  75.                                         
  76.     virtual  OSErr ResolveElementByIndex(DescType desiredClass,
  77.                                         short theIndex,
  78.                                         TScriptableObject **theResultObj);
  79.  
  80.     virtual  OSErr GetProperty  (DescType propertyID, DescType wantType, AEDesc *result);
  81.                                                 
  82.     virtual  OSErr SetProperty  (DescType propertyID, const AEDesc *theData);    
  83.                                         
  84.     virtual  OSErr GetObjectSpecifier  (AEDesc *result);
  85.                                         
  86.     virtual  OSErr GetTargetObjectSpecifier  (EventRecord& theEvent, AEDesc *result);
  87.  
  88.     virtual     OSErr CreateNewElement    (DescType desiredClass,
  89.                                         DescType position,
  90.                                         AEDesc *theData,
  91.                                         AERecord *theProperties,
  92.                                         TScriptableObject *theContainerObj,
  93.                                         TScriptableObject **theNewObj);
  94.  
  95.     virtual     void    FixUpScriptReferences(TScriptableObject* theParent);
  96.  
  97.             void    GetName(CStr255& theName)     { theName = fName; };
  98.  
  99.             WindowPtr    GetWindowPtr(void)     { return fWindowPtr; };
  100.             
  101. private:
  102.             void    InitLabels(void);
  103.             
  104. protected:
  105.     Boolean            fInitialized;
  106.     Rect            fBounds;
  107.     Boolean            fHasCloseBox;
  108.     Boolean            fHasTitleBar;
  109.     Boolean            fIsModal;
  110.     Boolean            fIsResizable;
  111.     Boolean            fIsZoomable;
  112.     Boolean            fIsZoomed;
  113.     CStr255            fName;
  114.     Boolean            fShouldBeVisible;
  115.     Boolean            fHasBeenCreated;
  116.     short            fWindowDefProc;
  117.     WindowPtr        fWindowPtr;
  118.     TListOfLongs    fButtonElems;    // list of *TInterfaceObj
  119.     TListOfLongs    fLabelElems;    // list of *TInterfaceObj
  120. };
  121.  
  122.  
  123. //
  124. // interface classes:
  125. //
  126. //        TInterfaceObj (defines all common properties of descendants)
  127. //              |
  128. //              |
  129. //        ______|______
  130. //        |            |
  131. //    TButtonObj    TLabelObj
  132. //
  133.  
  134.  
  135. /**********************************************************************
  136. ** class TInterfaceObj
  137. ***********************************************************************/
  138.  
  139. class TInterfaceObj : public TScriptableObject {
  140. public:
  141.                                 TInterfaceObj(TWindowObj* container);
  142.                                 TInterfaceObj(TWindowObj* container,
  143.                                                 const AEDesc *theData);
  144.     virtual                        ~TInterfaceObj();
  145.  
  146.     virtual    void    DrawObject (void);
  147.  
  148.     virtual    void    ForceRedrawObject (Boolean drawNow);
  149.  
  150.     virtual  OSErr ResolveContainer    (TScriptableObject **theContainerObj);
  151.  
  152.     virtual  OSErr GetProperty  (DescType propertyID, DescType wantType, AEDesc *result);
  153.                                                 
  154.     virtual  OSErr SetProperty  (DescType propertyID, const AEDesc *theData);    
  155.  
  156.                                         
  157.     virtual  OSErr GetObjectSpecifier  (AEDesc *result);
  158.  
  159.     virtual  DescType    GetClass(void);
  160.  
  161.             void    GetName(CStr255& theName)     { theName = fName; };
  162.  
  163.             void    GetBounds(Rect& theBounds)     { theBounds = fBounds; };
  164.             
  165. protected:
  166.     virtual  void    InitLabels(void);
  167.             
  168.     Boolean            fInitialized;
  169.     Rect            fBounds;
  170.     CStr255            fName;
  171.     CStr255            fFontName;
  172.     short            fFontSize;
  173.     short            fFontStyle;
  174.     RGBColor        fFgColor;
  175. };
  176.  
  177.  
  178.  
  179.  
  180. /**********************************************************************
  181. ** class TButtonObj
  182. ***********************************************************************/
  183.  
  184. class TButtonObj : public TInterfaceObj {
  185. public:
  186.                                 TButtonObj(TWindowObj* container);
  187.                                 TButtonObj(TWindowObj* container,
  188.                                             const AEDesc *theData);
  189.     virtual                        ~TButtonObj();
  190.  
  191.     virtual    void    DrawObject (void);
  192.  
  193.     virtual    void    ForceRedrawObject (Boolean drawNow);
  194.  
  195.     virtual  OSErr GetProperty  (DescType propertyID, DescType wantType, AEDesc *result);
  196.                                                 
  197.     virtual  OSErr SetProperty  (DescType propertyID, const AEDesc *theData);    
  198.  
  199.     virtual  DescType    GetClass(void);
  200.  
  201. protected:
  202.     virtual  void    InitLabels(void);
  203.             
  204.     DescType        fButtonKind;
  205.     ControlHandle    fControlH;
  206. };
  207.  
  208.  
  209.  
  210. /**********************************************************************
  211. ** class TLabelObj
  212. ***********************************************************************/
  213.  
  214. class TLabelObj : public TInterfaceObj {
  215. public:
  216.                                 TLabelObj(TWindowObj* container);
  217.                                 TLabelObj(TWindowObj* container,
  218.                                             const AEDesc *theData);
  219.     virtual                        ~TLabelObj();
  220.  
  221.     virtual    void    DrawObject (void);
  222.  
  223.     virtual    void    ForceRedrawObject (Boolean drawNow);
  224.  
  225.     virtual  OSErr GetProperty  (DescType propertyID, DescType wantType, AEDesc *result);
  226.                                                 
  227.     virtual  OSErr SetProperty  (DescType propertyID, const AEDesc *theData);    
  228.  
  229.     virtual  DescType    GetClass(void);
  230.     
  231. protected:
  232.     virtual  void    InitLabels(void);
  233.     
  234.     Handle        fContents;    // contents of Label, raw text
  235. };
  236.  
  237.  
  238.  
  239.  
  240. #endif
  241.